<template>
	<view class="mainPage crypt" :style="{'padding-top': `${$store.state.safeArea.top || 0}px`, 'padding-bottom': `${$store.state.safeArea.bottom || 0}px`}">
		<public-head :title="title"></public-head>
		<view class="passwords">
			<u-field v-model="oldpsw" label="原密码" placeholder="请输入原密码">
			</u-field>
			<u-field v-model="newpsw" label="新密码" placeholder="支持英文与数字" maxlength="16">
			</u-field>
			<u-field v-model="newpsws" label="确认密码" maxlength="16" placeholder="请再次输入新密码">
			</u-field>
		</view>
		<view>
			<view class="determines" v-if="oldpsw&&newpsw&&newpsws" @click="determines">确定</view>
			<view class="determine" v-else>确定</view>
		</view>
		<view class="forget" @click="toforgetpswd">忘记原密码？</view>
	</view>
</template>
<script>
var that
import publicHead from "@/components/publicHead/publicHead.vue"
export default {
	components: {
		publicHead
	},
	data() {
		return {
			title: "修改登录密码",
			oldpsw: '',
			newpsw: '',
			newpsws: '',
			isdetermine: 0,
			timer: null
		}
	},
	onLoad() {
		that = this
	},
	methods: {
		determines() {
			console.log('点击1')
			// if(that.newpsw.length<6||that.newpsw.length>16){
			// 	uni.showToast({
			// 		title: '请输入6-16位字符',
			// 		icon:'none',
			// 		duration: 2000
			// 	});
			// 	console.log('点击2')
			// }else
			if (that.newpsws !== that.newpsw) {
				uni.showToast({
					title: '两次输入的密码不一致',
					icon: 'none',
					duration: 2000
				});
				console.log('点击3')
			} else {
				that.$postAjax1('Doctor_doctorChangesPassword', {
					password: that.oldpsw,
					new_password: that.newpsw,
					repeat_password: that.newpsws
				}, function (data) {
					uni.showToast({
						title: '密码修改成功',
						duration: 2000
					});
					that.timer = setTimeout(() => {
						// 这里添加您的逻辑	
						uni.navigateBack({
						})
					}, 2000)
					console.log('点击4')
				})
			}
		},
		toforgetpswd() {
			uni.navigateTo({
				url: 'forgetpswd'
			})
		}
	}
}
</script>
<style scoped lang="scss">
.crypt {
	.determine {
		background: #c4c4c6;
		border-radius: 46rpx;
		margin: 100rpx 60rpx;
		padding: 24rpx 282rpx;
		color: #ffffff;
		font-size: 32rpx;
	}
	.determines {
		background: #ff8f2b;
		box-shadow: 0px 6rpx 8rpx 0px rgba(255, 143, 43, 0.2);
		border-radius: 46rpx;
		margin: 100rpx 60rpx;
		padding: 24rpx 282rpx;
		color: #ffffff;
		font-size: 32rpx;
	}
	.forget {
		position: absolute;
		bottom: 168rpx;
		font-size: 26rpx;
		color: #fe7600;
		text-align: center;
		width: 100%;
	}
}
</style>
